package com.zuoye.day03;

public class Person {
    private String name;
    private int age;
    private char gender;
    private String marry;

    //构造函数
    public Person(String name,int age,char gender,String marry){
        this.name = name;
        this.age = age;
        this.gender = gender;
        this.marry = marry;
    }
    public boolean canMarry(Person another){
        if (this == another)   //不能单指定一个属性相同！
            return false;
        if (!(another instanceof Person))  //另一个属于Person
            return false;
        if (this.gender == another.gender)
            return false;
        if (this.marry == "已婚" || another.marry == "已婚")
            return false;
        if ((this.gender == '男' && this.age >= 24 && another.gender == '女' && this.age >= 22) ||
                (this.gender == '女' && this.age >=22 && another.age >=24))
            return true;
        return false;
    }



    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public String getMarry() {
        return marry;
    }

    public void setMarry(String marry) {
        this.marry = marry;
    }
}
